<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="Expires" content="0"/>

    <title>顺发棋牌</title>
    <link type="text/css" rel="stylesheet" href="__STATIC__/game/css/style.css?v={$version|default='3'}"/>
    <script src="__STATIC__/game/js/main.js?v={$version|default='3'}"></script>
    <script src="__STATIC__/game/js/config.js?v={$version|default='3'}"></script>
    <script src="__STATIC__/game/js/layerm/layer.js?v={$version|default='3'}"></script>
    <script>

        GV.img_url = '__STATIC__/game/';

        var room_uuid = "{$room_uuid}";
        var round_turn = ""; //第几局
        var wsobj = null;
        //倒计时总秒数
        var seconds = 0;
        //倒计时定时器
        var main_timer = null;
        var lottery_timer = null;

        var lottery_num = {};
        var lottery_time = 0;
        var is_open_lottery = false;
        var IS_ENTER = false;

    </script>

</head>

<body onload="connectWs()">

<div class="largebox page_bg" id="largebox"
     style="overflow:hidden;background-image:url(__STATIC__/game/img/page_bg.jpg);">

    <section class="page_header">
        <div>
            <img src="__STATIC__/game/img/btn/back_btn.png" class="back_btn"/>

        </div>
        <div class="last_result">
            <span id="last_wan">
						1 <br/>
						小单
            </span>
            <span id="last_qian">
						1 <br/>
						小单
            </span>
            <span id="last_bai">
						1<br/>
						小单
			</span>
            <span id="last_shi">
						1<br/>
						小单
			</span>
            <span id="last_ge">
						1<br/>
						小单
			</span>
        </div>
        <div>
            <div class="head_center_left">
                <img src="__STATIC__/game/img/avatar.jpg" class="self_avatar_small"/> <br/>
                <span class="self_name_one"></span>
            </div>
            <div class="head_center_right">
                <span style="font-size:0.1rem;" id="round_turn">第0局</span> <br/>
                <span style="font-size:0.12rem;"><img src="__STATIC__/game/img/gold.png"
                                                      class="gold_small"/> <span id="number_top"></span></span><br/>
                <span style="color:#00be09;">负</span><span id="lost_num"></span> &nbsp;<span
                    style="color:#ff0a0a;">中 </span><span id="win_num"></span>
            </div>
        </div>
        <div>
            <div class="time_box">
                300
            </div>
            <div class="circleProgress_wrapper">
                <div class="wrapper right">
                    <div class="circleProgress rightcircle "></div>
                </div>
                <div class="wrapper left">
                    <div class="circleProgress leftcircle "></div>
                </div>
            </div>
        </div>
        <div class="draw_record_btn">
            <img src="__STATIC__/game/img/btn/bet_record_btn.png" width="100%"/>
        </div>
        <div class="reward_record_btn">
            <img src="__STATIC__/game/img/btn/reward_record_btn.png" width="100%"/>
        </div>
        <div class="explain_btn">
            <img src="__STATIC__/game/img/btn/explain_btn.png" width="100%"/>
        </div>
    </section>

    <section class="page_subtitle">
        <div class="float_left">
            <img src="__STATIC__/game/img/draw_number.png"/>
        </div>
        <div class="float_right">
            <div class="lottery_unit">
                <span>万位</span>
                <span>千位</span>
                <span>百位</span>
                <span>十位</span>
                <span>个位</span>
            </div>
            <div class="lottery_box">
                <div class="lottery_div" id="wan"><span>0</span></div>
                <div class="lottery_div" id="qian"><span>0</span></div>
                <div class="lottery_div" id="bai"><span>0</span></div>
                <div class="lottery_div" id="shi"><span>0</span></div>
                <div class="lottery_div" id="ge"><span>0</span></div>
            </div>
        </div>
        <div class="clearfix"></div>
        <img src="__STATIC__/game/img/btn/two_words_btn.png" class="two_words_btn"/>
    </section>

    <!--大小单双-->
    <section class="page_main page_main_unit">
        <div class="big_area clearfix" style="background-image: url(__STATIC__/game/img/big.png);" data-area="big">
            <div class="unit_btn wan" data-click="0" data-unit="wan">
            </div>
            <div class="unit_btn qian" data-click="0" data-unit="qian">
            </div>
            <div class="unit_btn bai" data-click="0" data-unit="bai">
            </div>
            <div class="unit_btn shi" data-click="0" data-unit="shi">
            </div>
            <div class="odds">1:20</div>
        </div>
        <div class="small_area clearfix" style="background-image: url(__STATIC__/game/img/small.png);"
             data-area="small">
            <div class="unit_btn wan" data-click="0" data-unit="wan">

            </div>
            <div class="unit_btn qian" data-click="0" data-unit="qian">

            </div>
            <div class="unit_btn bai" data-click="0" data-unit="bai">

            </div>
            <div class="unit_btn shi" data-click="0" data-unit="shi">

            </div>
            <div class="odds">1:20</div>
        </div>
        <div class="single_area clearfix" style="background-image: url(__STATIC__/game/img/single.png);"
             data-area="single">
            <div class="unit_btn wan" data-click="0" data-unit="wan">

            </div>
            <div class="unit_btn qian" data-click="0" data-unit="qian">

            </div>
            <div class="unit_btn bai" data-click="0" data-unit="bai">

            </div>
            <div class="unit_btn shi" data-click="0" data-unit="shi">

            </div>
            <div class="odds">1:20</div>
        </div>
        <div class="double_area clearfix" style="background-image: url(__STATIC__/game/img/double.png);"
             data-area="double">
            <div class="unit_btn wan" data-click="0" data-unit="wan">

            </div>
            <div class="unit_btn qian" data-click="0" data-unit="qian">

            </div>
            <div class="unit_btn bai" data-click="0" data-unit="bai">

            </div>
            <div class="unit_btn shi" data-click="0" data-unit="shi">

            </div>
            <div class="odds">1:20</div>
        </div>
    </section>

    <section class="page_main page_main_draw">
        <div class="draw_big_area">
            <span class="number" id="big_total">0</span>
        </div>
        <div class="draw_small_area">
            <span class="number" id="small_total">0</span>
        </div>
        <div class="draw_single_area">
            <span class="number" id="single_total">0</span>
        </div>
        <div class="draw_double_area">
            <span class="number" id="double_total">0</span>
        </div>
    </section>

    <section class="page_footer">
        <div class="self_big_avatar">
            <img src="__STATIC__/game/img/avatar.jpg"/>
        </div>
        <div class="self_gold_number">
            <div class="self_name"></div>
            <span><img src="__STATIC__/game/img/gold.png" class="gold_small"/> <span id="number">0</span></span>
        </div>
        <div class="coin" id="coin_1" data-price="10" data-type="1">
            10
        </div>
        <div class="coin" id="coin_2" data-price="50" data-type="2">
            50
        </div>
        <div class="coin" id="coin_3" data-price="100" data-type="3">
            100
        </div>
        <div class="coin" id="coin_4" data-price="500" data-type="4">
            500
        </div>
        <div class="coin" id="coin_5" data-price="1000" data-type="5">
            1000
        </div>
        <div class="draw_again_btn">
            <!--投注按钮-->
            <img src="__STATIC__/game/img/btn/draw.png"/>
            <!--<img src="img/btn/draw_again.png"/>-->
        </div>
    </section>

    <div class="seat_list">
        <section class="partner_avatar_section partner_avatar_left_1" id="seat_1">
            <div class="partner_avatar">
                虚位以待
            </div>
        </section>
        <section class="partner_avatar_section partner_avatar_left_2" id="seat_2">
            <div class="partner_avatar">
                虚位以待
            </div>
        </section>
        <section class="partner_avatar_section partner_avatar_left_3" id="seat_3">
            <div class="partner_avatar">
                虚位以待
            </div>
        </section>
        <section class="partner_avatar_section partner_avatar_right_4" id="seat_4">
            <div class="partner_avatar">
                <!--<img src="img/avatar.jpg" />-->
                虚位以待
            </div>
            <!--小倩-->
        </section>
        <section class="partner_avatar_section partner_avatar_right_5" id="seat_5">
            <div class="partner_avatar">
                虚位以待
            </div>
        </section>
        <section class="partner_avatar_section partner_avatar_right_6" id="seat_6">
            <div class="partner_avatar">
                虚位以待
            </div>
        </section>
    </div>

    <!--开奖记录-->
    <section class="overlay_box reward_record_overlay">
        <div class="overlay_head">开奖记录</div>
        <div class="overlay_main reward_record_list">
            <div class="overlay_main_content">
                <div class="reward_record record_head">
                    <div><i>开奖号码</i></div>
                    <div><i>期数</i></div>
                    <div><i>时间</i></div>
                </div>
                <div id="content_lottery"></div>

            </div>
        </div>
        <div class="cancel"><img src="__STATIC__/game/img/cancel.png" width="100%"/></div>
    </section>

    <!--投注记录-->
    <section class="overlay_box draw_record_overlay">
        <div class="overlay_head">投注记录</div>
        <div class="overlay_main draw_record_list">
            <div class="overlay_main_content">
                <div class="draw_record record_head">
                    <div><i>期数</i></div>
                    <div><i>投注号码</i></div>
                    <div><i>金额</i></div>
                    <div><i>状态</i></div>
                </div>
                <div id="bet_log_content">

                </div>
            </div>

        </div>
        <div class="overlay_foot">
            &nbsp;&nbsp;&nbsp;总投金额：<span id="draw_price">0</span> &nbsp;&nbsp;&nbsp;中：
            <span id="win_price">0 </span> &nbsp;&nbsp;&nbsp;负：
            <span id="lose_price">0</span>
        </div>
        <div class="cancel"><img src="__STATIC__/game/img/cancel.png" width="100%"/></div>
    </section>

    <!--二星定位-->
    <section class="overlay_box two_star_overlay">
        <div class="overlay_head">二星定位</div>
        <div class="overlay_main">
            <div class="overlay_main_content">
                <p style="line-height: 16px;margin-top:3px;">
                    在任意2位中选择号码下注，选号与开奖号码相同且位置相同即为中奖
                </p>
                <div class="two_star_box" data-unit="wan">
                    <div>
                        万位
                    </div>
                    <div class="select_number_box">
                        <span data-small='1' data-double='1' data-number="0">0</span>
                        <span data-small='1' data-single='1' data-number="1">1</span>
                        <span data-small='1' data-double='1' data-number="2">2</span>
                        <span data-small='1' data-single='1' data-number="3">3</span>
                        <span data-small='1' data-double='1' data-number="4">4</span>
                        <span data-big='1' data-single='1' data-number="5">5</span><br/>
                        <span data-big='1' data-double='1' data-number="6">6</span>
                        <span data-big='1' data-single='1' data-number="7">7</span>
                        <span data-big='1' data-double='1' data-number="8">8</span>
                        <span data-big='1' data-single='1' data-number="9">9</span><br/>
                        <label data-area="big">大</label>
                        <label data-area="small">小</label>
                        <label data-area="single">单</label>
                        <label data-area="double">双</label>
                        <label data-area="all">全</label>
                        <label data-area="clear">清</label>
                    </div>
                </div>
                <div class="two_star_box" data-unit="qian">
                    <div>
                        千位
                    </div>
                    <div class="select_number_box">
                        <span data-small='1' data-double='1' data-number="0">0</span>
                        <span data-small='1' data-single='1' data-number="1">1</span>
                        <span data-small='1' data-double='1' data-number="2">2</span>
                        <span data-small='1' data-single='1' data-number="3">3</span>
                        <span data-small='1' data-double='1' data-number="4">4</span>
                        <span data-big='1' data-single='1' data-number="5">5</span><br/>
                        <span data-big='1' data-double='1' data-number="6">6</span>
                        <span data-big='1' data-single='1' data-number="7">7</span>
                        <span data-big='1' data-double='1' data-number="8">8</span>
                        <span data-big='1' data-single='1' data-number="9">9</span><br/>
                        <label data-area="big">大</label>
                        <label data-area="small">小</label>
                        <label data-area="single">单</label>
                        <label data-area="double">双</label>
                        <label data-area="all">全</label>
                        <label data-area="clear">清</label>
                    </div>
                </div>
                <div class="two_star_box" data-unit="bai">
                    <div>
                        百位
                    </div>
                    <div class="select_number_box">
                        <span data-small='1' data-double='1' data-number="0">0</span>
                        <span data-small='1' data-single='1' data-number="1">1</span>
                        <span data-small='1' data-double='1' data-number="2">2</span>
                        <span data-small='1' data-single='1' data-number="3">3</span>
                        <span data-small='1' data-double='1' data-number="4">4</span>
                        <span data-big='1' data-single='1' data-number="5">5</span><br/>
                        <span data-big='1' data-double='1' data-number="6">6</span>
                        <span data-big='1' data-single='1' data-number="7">7</span>
                        <span data-big='1' data-double='1' data-number="8">8</span>
                        <span data-big='1' data-single='1' data-number="9">9</span><br/>
                        <label data-area="big">大</label>
                        <label data-area="small">小</label>
                        <label data-area="single">单</label>
                        <label data-area="double">双</label>
                        <label data-area="all">全</label>
                        <label data-area="clear">清</label>
                    </div>
                </div>
                <div class="two_star_box" data-unit="shi">
                    <div>
                        十位
                    </div>
                    <div class="select_number_box">
                        <span data-small='1' data-double='1' data-number="0">0</span>
                        <span data-small='1' data-single='1' data-number="1">1</span>
                        <span data-small='1' data-double='1' data-number="2">2</span>
                        <span data-small='1' data-single='1' data-number="3">3</span>
                        <span data-small='1' data-double='1' data-number="4">4</span>
                        <span data-big='1' data-single='1' data-number="5">5</span><br/>
                        <span data-big='1' data-double='1' data-number="6">6</span>
                        <span data-big='1' data-single='1' data-number="7">7</span>
                        <span data-big='1' data-double='1' data-number="8">8</span>
                        <span data-big='1' data-single='1' data-number="9">9</span><br/>
                        <label data-area="big">大</label>
                        <label data-area="small">小</label>
                        <label data-area="single">单</label>
                        <label data-area="double">双</label>
                        <label data-area="all">全</label>
                        <label data-area="clear">清</label>
                    </div>
                </div>
            </div>
        </div>
        <div class="overlay_foot">
            注数：<span id="draw_num">0</span> &nbsp;&nbsp; 金额：
            <input type="text" name="ave_price" onkeyup="clearNoNum(this)" value="0"/>&nbsp;&nbsp;
            <span>元</span>&nbsp;

            <div class="btn_box">
                <div class="clear_all_btn">清空</div>
                <div class="random_btn">机选</div>
                <div class="two_star_draw_btn">立即下注</div>
                <div>合计<span id="total_price">0</span>元</div>
            </div>
        </div>
        <div class="cancel"><img src="__STATIC__/game/img/cancel.png" width="100%"/></div>
    </section>

    <section class="overlay_box how_to_play" style="width:33%">
        <div class="overlay_head">玩法说明</div>
        <div class="overlay_main">
            <div class="overlay_main_content" style="width:100%">
                任意对应位置大小单双<br/>
                如 万位、千位、 百位、 十位“大（56789）小（01234）、单（13579）双（02468）<br/>
                形态进行购买，所选号码的位置、形态与开奖号码的位置、形态相同，即为中奖。<br/>
                大小单双赔率 1 赔 1.96<br/>

                任二直选二字定位<br/>
                从万位、千位、百位、十位、个位中任意选择两个位置，在这两个位置上至少各选1个号码组成一注，所选2个位置上的开奖号码与所选号码完全相同，且顺序一致，即为中奖。
                <br/>
                二字定位赔率 1 赔 97<br/>

            </div>
        </div>
        <div class="overlay_foot">
        </div>
        <div class="cancel"><img src="__STATIC__/game/img/cancel.png" width="100%"/></div>
    </section>

    <!--提示-->
    <img src="__STATIC__/game/img/start.png" class="draw_tip start_draw"/>
    <img src="__STATIC__/game/img/stop.png" class="draw_tip stop_draw"/>
    <div class="tip_box"></div>

    <!--音效-->
    <audio loop="loop" id="bg_music">
        <source src="__STATIC__/game/audio/bg.mp3" type="audio/mpeg">
    </audio>
    <audio src="__STATIC__/game/audio/click_btn.mp3" id="click_btn_music">
        您的浏览器不支持 audio 标签。
    </audio>
    <audio src="__STATIC__/game/audio/draw_gold.mp3" id="draw_gold_music">
        您的浏览器不支持 audio 标签。
    </audio>


</div>
<a id="play_time"></a>

<script type="text/javascript" src="__STATIC__/game/js/jquery-2.0.0.min.js"></script>
<!--<script type="text/javascript" src="__STATIC__/game/js/fastclick.js"></script>
<script type="application/javascript">
    window.addEventListener('load', function() {
        FastClick.attach(document.body);
    }, false);
</script>-->
<script type="text/javascript" src="__STATIC__/js/swfobject.js"></script>
<script type="text/javascript" src="__STATIC__/js/web_socket.js"></script>
<script>
    function clearNoNum(obj) {
//先把非数字的都替换掉，除了数字和.
        obj.value = obj.value.replace(/[^\d.]/g, "");
//必须保证第一个为数字而不是.
        obj.value = obj.value.replace(/^\./g, "");
//保证只有出现一个.而没有多个.
        obj.value = obj.value.replace(/\.{2,}/g, ".");
//保证.只出现一次，而不能出现两次以上
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        if (obj.value < 0) {
            obj.value = (-obj.value);
        }
    }

    var uid = '';
    $(function () {
        $('#play_time')[0].click();

        setTimeout(function () {
            //audioAutoPlay('bg_music');
        }, 3000)

    });
    $(document).on('click', '#play_time', function (e) {
        audioAutoPlay('bg_music')

    });


    // var
</script>

<script>
    var user_uuid = "{$user.user_uuid}";
    var user_nick = "{$user.user_nick}";
    var user_name = "{$user.user_name}";
    var ws_protocal = 'ws://';
    var token = '{$user.token}';
    var protocal = document.location.protocol;
    if (protocal == 'https:') {
        ws_protocal = 'wss://';
    }


    // 如果浏览器不支持websocket，会使用这个flash自动模拟websocket协议，此过程对开发者透明
    WEB_SOCKET_SWF_LOCATION = "__STATIC__/swf/WebSocketMain.swf";
    // 开启flash的websocket debug
    WEB_SOCKET_DEBUG = true;
    var ws, name, client_list = {};

    var getExplorer = (function () {
        var explorer = window.navigator.userAgent,
            compare = function (s) {
                return (explorer.indexOf(s) >= 0);
            },
            ie11 = (function () {
                return ("ActiveXObject" in window)
            })();
        if (compare("MSIE") || ie11) {
            return 'ie';
        } else if (compare("Firefox") && !ie11) {
            return 'Firefox';
        } else if (compare("Chrome") && !ie11) {
            if (explorer.indexOf("Edge") > -1) {
                return 'Edge';
            } else {
                return 'Chrome';
            }
        } else if (compare("Opera") && !ie11) {
            return 'Opera';
        } else if (compare("Safari") && !ie11) {
            return 'Safari';
        }

    })();

    function decodeUTF8(arr) {
        var str = '';
        for (var i = 0; i < arr.length; i++) {
            str += String.fromCharCode(arr[i]);
        }
        return decodeURIComponent(escape(str));
    }

    function binaryData(ev) {
        if (getExplorer == 'Edge') {
            return JSON.parse(decodeUTF8(new Uint8Array(ev.data)));
        }

        return JSON.parse(new TextDecoder("utf-8").decode(new Uint8Array(ev.data)))
    }


    // 连接服务端
    function connectWs() {
        // 创建websocket
        ws = new WebSocket(ws_protocal + GV.socket_url);
        wsobj = ws;
        ws.binaryType = 'arraybuffer';
        // 当socket连接打开时，输入用户名
        ws.onopen = onopen;
        // 当有消息时根据消息类型显示不同信息
        ws.onmessage = onmessage;
        ws.onclose = function (e) {
            console.log(e)
            connectWs();
            // if (!ServerForceClose) {
            //     connectWs();
            // }
        };
        ws.onerror = function () {
            console.log("出现错误");
        };
    }


    // 连接建立时发送登录信息
    function onopen() {
        enter_room();
    }


    // 服务端发来消息时
    function onmessage(e) {
        var data = JSON.parse(e.data);

        switch (data['type']) {
            case 'ping':
                ws.send('{"action":"pong"}');
                break;
            case 'init':
                if (data['is_login']) {
                    IS_ENTER = true;
                    setCookie('is_login_' + room_uuid, 1, 1);
                }
                renderInit(data);
                renderLastLottery(data);
                break;
            case 'new_turn':
                requestUserInfo();
                break;
            case 'open_lottery':
                lottery_num = data['content']['lottery_number'];
                open_lottery_and_reset(data['content']['lottery_number']);
                break;
            case 'update_user_info':
                renderLastLottery(data);
                var rate = data['content'];
                $('#number').html(rate.own_info.coin)
                $('#number_top').html(rate.own_info.coin)
                $('#lost_num').html(rate.game.lose);
                $('#win_num').html(rate.game.win)
                break;
            case 'update_players':
                renderInit(data);
                break;
            case 'draw_coin':

                drawCoin(data);
                setAreaCount(data['lottery_num']);
                break
            case 'logout':
                update_online_users();
                break;
            case 'close':
                if(data['event'] == 'user_full'){
                    set_alert('tip', '当前房间已满员', null, true);
                    set_mask();
                }
        }

    }

    /************/
    function drawCoin(data) {
        if (data['from_uuid'] != user_uuid) {
            setTimeout(function () {
                handle_drop_coin(data);
            }, 500);

        }

    }

    function setAreaCount(data) {
        for (var i in data) {
            $('#' + i + '_total').html(data[i]);
        }
    }

    /*************/

    function requestUserInfo() {
        var datas = {
            action: "get_user_info",
            content: {}
        };
        ws.send(JSON.stringify(datas));
    }

    function renderInit(data) {
        var list = data['list'];
        var max = 6;
        var str = '';
        var o = 'right';
        for (var i = 0; i < max; i++) {
            if (i < 3) {
                o = 'left';

            } else {
                o = 'right';
            }
            if (list[i]) {
                str += '<section class="partner_avatar_section partner_avatar_' + o + '_' + (i + 1) + '" id="seat_' + (i + 1) + '" data-uuid="' + list[i].user_uuid + '">' +
                    '<div class="partner_avatar" uuid="' + list[i].user_uuid + '" data-uuid="' + list[i].user_uuid + '">' +
                    '<img src="' + (list[i].headimg ? list[i].headimg : '__STATIC__/game/img/avatar.jpg') + '"/>' +
                    '</div>' +
                    list[i].user_nick +
                    '</section>'
            } else {
                str += '<section class="partner_avatar_section partner_avatar_' + o + '_' + (i + 1) + '" id="seat_' + (i + 1) + '">' +
                    '<div class="partner_avatar">' +
                    '<!--<img src="img/avatar.jpg" />-->' +
                    '虚位以待' +
                    '</div>' +
                    '</section>';

            }

        }
        $('.seat_list').html(str);
    }


    function send(data) {
        ws.send(data)
    }

    function update_online_users() {
        var init_data = {
            action: 'update_online_users',
            content: {}
        }
        send(JSON.stringify(init_data));
    }

    function enter_room() {
        var auth_data =
            {
                action: 'login',
                content: {
                    room_id: room_uuid,
                    user_uuid: user_uuid,
                    user_nick: user_nick,
                    user_name: user_name,
                }
            };
        send(JSON.stringify(auth_data));
    }

    function renderLastLottery(data) {
        var data_number = data.last_lottery;
        for (var i in data_number) {
            $('#last_' + i).html(data_number[i].value + "<br/>" + data_number[i].type_arr_l);
        }
    }


</script>

<script type="text/javascript" src="__STATIC__/game/js/index.js?v={$version|default='3'}"></script>
<script type="text/javascript" src="__STATIC__/game/js/main_timer.js?v={$version|default='3'}"></script>
<script type="text/javascript" src="__STATIC__/game/js/draw_gold.js?v={$version|default='3'}"></script>

<script type="text/javascript" src="__STATIC__/game/js/two_star.js?v={$version|default='3'}"></script>

<script>

    function open_lottery_and_reset(data) {

        setTimeout(function () {
            reset_number(data);
            if (seconds <= 0) {
                setLeftTime(10);
            }
            setTimeout(function () {
                getRoundInfo();
                clearLotteryTimer();
            }, 5000);
        }, 1000);
    }

    function setLeftTime(left_time) {
        clearTimeOut();
        seconds = left_time;
        startTimoOut();

    }

    function calc_left_time(open_time) {
        var tmp = Date.parse(new Date()).toString();
        var left;
        tmp = tmp.substr(0, 10);
        left = open_time - tmp;
        return left;

    }

    function setTurnName(title) {
        $('#round_turn').html(title);
    }

    // 请求信息类

    function getRoundInfo() {
        request(GV.url + 'Game/getCurrentRound', {}, function (json) {
            if (json.ResponseStatus == 0) {
                // var time_remain = calc_left_time(json.datas.open_time);
                // if (time_remain > 0) {
                setLeftTime(json.datas.left_time);
                setTurnName(json.datas.round_name);
                round_turn = json.datas.round_period;
                $('.tip_box').hide();
                clearLotterydesktop();

                // clearLotteryNumber();
                // }

                if (json.datas.last_lottery) {
                    var data = {
                        last_lottery: json.datas.last_lottery
                    }
                    renderLastLottery(data)
                    setLotteryNumber(json.datas.lottery_number)
                }
            } else {
                set_alert('tip', json.ResponseMsg, null, true);
                set_mask();
            }
        });

    }

    function clearLotterydesktop() {
        $('#big_total').html(0)
        $('#small_total').html(0)
        $('#double_total').html(0)
        $('#single_total').html(0)
    }

    function renderUserinfo() {
        $.ajax({
            url: GV.url + 'User/getUserInfo',
            type: "POST",
            data: {token: token},
            dataType: "json",
            success: function (data) {
                if (data.ResponseStatus == 0) {
                    var rate = data.datas;
                    $('.self_name').html(rate.user_info.user_nick);
                    $('.self_name_one').html(rate.user_info.user_nick);
                    $('#number').html(rate.user_info.coin)
                    $('#number_top').html(rate.user_info.coin)
                    $('#lost_num').html(rate.battle_info.lost);
                    $('#win_num').html(rate.battle_info.win)
                    if (rate.user_info.headimg) {
                        $('img.self_avatar_small').attr('src', rate.user_info.headimg);
                        $('.self_big_avatar').find('img').attr('src', rate.user_info.headimg)
                    }
                }
            }
        });
    }

    function getLotteryLog() {
        var str = '';
        request(GV.url + 'Game/getLastLotteryList', {}, function (json) {
            if (json.ResponseStatus == 0) {
                var data = json.datas;
                for (var o in data) {
                    str += '<div class="reward_record">' +
                        '<div class="reward_record_result">';

                    for (var i in data[o]['lottery_number']) {
                        str += '<span>' + data[o]['lottery_number'][i]['value'] + '  <br/>' + data[o]['lottery_number'][i]['type_arr_l'] + ' </span>'

                    }
                    str += '</div>' +
                        '<div style="overflow-wrap: break-spaces">' + data[o]['round_circle'] + '</div>' +
                        '<div>' + data[o]['open_time'] +
                        '</div>' +
                        '</div>'
                }

                $('#content_lottery').html(str);
            }

        })
    }

    function getBetLog() {
        var str = '';
        request(GV.url + 'Game/getBetLog', {}, function (json) {
            if (json.ResponseStatus == 0) {
                var data = json.datas.list;
                var detail = json.datas.bet_sum;

                var str = '';
                for (var o in data) {

                    str += "<div class=\"draw_record mc-center\">" +
                        "<div>" + data[o]['round_turn'] + "</div>" +
                        "<div>" +
                        data[o]['info'] +
                        "</div>" +
                        "<div>" + data[o]['amount'] + "</div>" +
                        "<div>" + data[o]['status'] + "</div>" +
                        "</div>"

                }
                $('#bet_log_content').html(str);
                $('#draw_price').html(detail.total);
                $('#win_price').html(detail.win);
                $('#lose_price').html(detail.lose)

            }

        })
    }

    function getOpenLotteryNumber() {
        var data = {
            'turn': round_turn
        };
        request(GV.url + 'Game/getNewLotteryNumber', data, function (data) {
            if (data.ResponseStatus == 0) {
                open_lottery_and_reset(data.datas.lottery_num);
                console.log(lottery_timer);
                clearLotteryTimer();
                console.log(lottery_timer);
            } else {
            }

        });
    }


    $(function () {
        getRoundInfo();
        renderUserinfo();
        getLotteryLog();
        getBetLog();
    });

    //返回
    $(".back_btn").on("click", function () {
        setCookie('is_login_' + room_uuid, 0, 0);
        update_online_users();
        ws.close();
        window.location.replace('{:url("index/index/index")}');
    });


</script>
<style>
    .mc-center {
        text-align: center;
    }

    .draw_record_overlay {
        top: 0.1rem !important;

    }

    .two_star_overlay .overlay_main {
        height: 2.3rem !important;
    }
</style>

<!--要投掷下去的金币都添加在这里-->
<div class="draw_golds_div">
    <!--<img src="img/coin/1.png"/>-->
</div>

<div class="content"></div>
<div class="" style="position: fixed;
    background: rgba(0,0,0,0.6);
    width: 10000px;
    height: 1000px;
    top: 0;
    z-index: 8;display:none" id="mask">

</div>
</body>

</html>